package com.tjwx.service.impl;

import com.tjwx.dao.ClassifyMapper;
import com.tjwx.model.JsonModel;
import com.tjwx.service.ClassifyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service("classifyService")
public class ClassifyServiceImpl implements ClassifyService {

    Logger log = LoggerFactory.getLogger(ClassifyServiceImpl.class);
    @Autowired
    ClassifyMapper classifyMapper;


    @Override
    public JsonModel getClassify() {
        List<Map<String,Object>> classifies = classifyMapper.getClassify(null);
        //如果需要有层级，此处添加递归算法，计算层级
        JsonModel jsonModel = new JsonModel(true,"查询分类成功","0000",classifies);
        return jsonModel;
    }

    @Override
    public JsonModel getDetailByClassifyid(String classifyid) {
        Map map = new HashMap(2);
        map.put("classifyid",classifyid);
        List<Map<String,Object>> classifies = classifyMapper.getDetailByClassifyid(map);
        //如果需要有层级，此处添加递归算法，计算层级
        JsonModel jsonModel = new JsonModel(true,"查询分类详情成功","0000",classifies);
        return jsonModel;
    }
}
